//
//  XMLatelyVisitorsViewController.m
//  XMJJ_zml
//
//  Created by 丁浩 on 2025/5/21.
//

#import "XMLatelyVisitorsViewController.h"
#import "XMLatelyVisitorsView.h"
#import "XMNetwork+mine.h"
#import "XMLatelyVisitorModel.h"

@interface XMLatelyVisitorsViewController ()<XMLatelyVisitorsViewDelegate>

@property (nonatomic, strong) XMLatelyVisitorsView *latelyVisitorView;

@property (nonatomic, assign) NSInteger page;

@end

@implementation XMLatelyVisitorsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self creatUI];
}

- (void)creatUI {
    [self.view addSubview:self.latelyVisitorView];
    [self getLatelyVisitors];
}

- (void)getLatelyVisitors {
    XMWeakSelf;
    [_Network getLatelyVisitorsSuccess:^(id  _Nonnull responseObject) {
        NSArray *latelyVisitorsModelArr = [NSArray yy_modelArrayWithClass:[XMLatelyVisitorModel class] json:responseObject[@"data"]];
        [weakSelf.latelyVisitorView setContentWithUserModelArr:latelyVisitorsModelArr page:weakSelf.page];
    } failure:^(NSError * _Nonnull error) {
        
    }];
}

#pragma mark - Init
- (void)refreshData {
    _page = 0;
    [_latelyVisitorView setContentWithUserModelArr:@[] page:_page];
}

- (void)loadMore {
    _page += 1;
    [_latelyVisitorView setContentWithUserModelArr:@[] page:_page];
}

- (void)checkUser {
    
}

#pragma mark - Init
- (XMLatelyVisitorsView *)latelyVisitorView {
    if (!_latelyVisitorView) {
        _latelyVisitorView = [[XMLatelyVisitorsView alloc] initWithFrame:self.view.bounds];
       _latelyVisitorView.delegate = self;
        [_latelyVisitorView setContentWithUserModelArr:@[] page:1];
    }
    return _latelyVisitorView;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
